package com.jk.utile;


import com.jk.vo.UserInfo;
import com.jk.vo.UserLoginLog;
import org.apache.ibatis.jdbc.SQL;

public class UserDynaSqlProvider {

    public String checkNumberOrId(final UserInfo user)
    {
        return new SQL() {{
            SELECT("count(1)");
            FROM("user_login");
            if (user != null){
                if (user.getUserNumber() != null) {
                    WHERE("user_number=#{userNumber}");
                }
                if(user.getUserId()!=null){
                    WHERE("user_id=#{userId}");
                }
            }else{  //防止 对象 恶意为空
                WHERE("1=2");
            }
        }}.toString();
    }
    public String checkIp(final UserLoginLog userLog)
    {
        return new SQL() {{
            SELECT("count(1)");
            FROM("user_login_log");
            WHERE("log_login_ip=#{logLoginIp} and log_user_id=#{logUserId}");
        }}.toString();
    }


}
